﻿using Bigway.Common.Models.DbModels;
using Bigway.Common.Utils;
using SqlSugar;

namespace Benefactor.Models.DbModels;

public class BenefitsCard: DeletableEntity
{
    [SugarColumn(IsNullable = false)]
    public string Name { get; set; }

    [SugarColumn(IsNullable = false)]
    public string Description { get; set; }

    [SugarColumn(IsNullable = true)]
    public double Price { get; set; }

    [SugarColumn(IsNullable = true)]
    public double? RefererFee { get; set; } // 推广人分润

    private string? _imageUrl;
    [SugarColumn(IsNullable = false)]
    public string ImageUrl
    {
        get => UrlUtils.GetAbsoluteUrl(Statics.AppConfig.FileApiBaseUrl, _imageUrl);
        set => _imageUrl = UrlUtils.GetRelativeUrl(value);
    }

    [SugarColumn(IsNullable = true)]
    public string? DistrictId { get; set; }

    [SugarColumn(IsNullable = true)]
    public string? DistrictPrefix { get; set; }

    [SugarColumn(IsNullable = true)]
    public double? DistrictLatitude { get; set; }

    [SugarColumn(IsNullable = true)]
    public double? DistrictLongitude { get; set; }

    [SugarColumn(IsNullable = true)]
    public double? DistrictAltitude { get; set; }

    [SugarColumn(IsNullable = true)]
    public string? MerchantProductId { get; set; }

    [Navigate(NavigateType.OneToMany, nameof(IssuedBenefitsCard.BenefitsCardId))]
    public List<IssuedBenefitsCard>? IssuedBenefitsCards { get; set; }

    [Navigate(NavigateType.OneToMany, nameof(Benefit.BenefitsCardId))]
    public List<Benefit>? Benefits { get; set; }
}